package com.wolfalpha.utron.activity.base;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.umeng.analytics.MobclickAgent;
import com.wolfalpha.utron.R;
import com.wolfalpha.utron.app.AppManager;

/**
 * 包含了头部左侧和中部以及右部文字的Activity
 * <p/>
 * Created by luodon on 15/8/18.
 */
public class BaseNormal3Activity extends Activity {

    private TextView tvLeft;               //返回按钮
    private TextView tvTitle;               //标题
    private TextView tvRight;              //右侧的操作


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        AppManager.getAppManager().addActivity(this);
    }

    /**
     * 初始化头部界面
     */
    public void initHead() {
        tvLeft = (TextView) findViewById(R.id.header_tv_left);
        tvTitle = (TextView) findViewById(R.id.header_tv_title);
        tvRight = (TextView) findViewById(R.id.header_tv_right);

        tvLeft.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        tvRight.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                rightOperation();
            }
        });
    }

    /**
     * 在子类的onCreate中调用
     *
     * @param title
     */
    public void setTvTitle(String title) {
        initHead();
        tvTitle.setText(title);
    }

    /**
     * 设置右侧按钮 的文字
     *
     * @param right
     */
    public void setRightText(String right) {
        tvRight.setText(right);
    }

    /**
     * 留给父类实现
     * <p/>
     * 点击右侧按钮时触发
     */
    public void rightOperation() {


    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        AppManager.getAppManager().finishActivity(this);
    }

    public void onResume() {
        super.onResume();
        //友盟统计
        MobclickAgent.onResume(this);
    }

    public void onPause() {
        super.onPause();
        //友盟统计
        MobclickAgent.onPause(this);
    }
}
